import type { NuxtConfig } from "nuxt/config";

// @ts-ignore
export default defineNuxtConfig({
  ssr: true,
  compatibilityDate: '2025-07-15',
  devtools: { enabled: true },
  modules: [
    '@nuxt/ui',
    '@nuxt/image',
    '@nuxt/icon',
    '@pinia/nuxt',
    'pinia-plugin-persistedstate/nuxt',
    '@unocss/nuxt',
    '@nuxtjs/robots',
    '@nuxtjs/sitemap',
    'nuxt-og-image',
    '@nuxtjs/i18n'
  ],
  // 配置路径别名
  // alias: {
  //   '@': '/app',
  //   '~': './app',
  // },
  ui: {
    fonts: false
  },
  devServer: {
    host: "", //默认值:localhost
    https: false, //是否开启https
    port: 8081, //监听端口 默认"8081"
    url: "http://localhost:8081", //监听url
  },
  debug: true,
  experimental: {
    writeEarlyHints: false
  },
  // 运行时配置，使用：const runtimeConfig = useRuntimeConfig() -- runtimeConfig.public.version
  runtimeConfig: {
    public: {
      baseUrl: process.env.NUXT_PUBLIC_API_BASE_URL,
      version: process.env.NUXT_PUBLIC_VERSION,
      siteUrl: 'https://www.hrkes17.com',
      siteName: 'My Awesome Website',
    },
  },
  // 配置使用本地icon
  // svg的文件，使用：<Icon name="my-icon:bar-outline" />
  icon: {
    customCollections: [
      {
        prefix: 'my-icon',
        dir: './assets/my-icons'
      },
    ],
  },
  pinia: {
    storesDirs: ['./stores/**'],
  },
  // 测试自定义插件的使用方法
  plugins: [
    { src: "~/plugins/appLifeCircle.ts" },
  ],
  // scss 全局变量的配置
  css: ["~/assets/scss/global.scss"],
  vite: {
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: '@use "~/assets/scss/_vars.scss" as *;'
        },
      },
    },
  },
  site: {
    url: 'https://hrkes17.com',
    name: 'My Awesome Website'
  },
  // <NuxtImg /> 组件的配置,
  image: {
    dir: 'assets/images'
  },
  // i18n 配置
  // detectBrowserLanguage自动检测浏览器语言，对爬虫相对友好
  i18n: {
    defaultLocale: 'zh',
    locales: [
      { code: 'en', name: 'English', file: 'en.json', language: 'en-US' },
      { code: 'zh', name: 'Chinese', file: 'zh.json', language: 'zh-CN' }
    ],
    seo: true, // 自动生成hreflang
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: 'i18n_redirected',
      redirectOn: 'root' // recommended
    }
  }
} as NuxtConfig)